package com.example.myapplication.kotlin

//帮我卸一个入口函数输出 ‘你好鸿蒙’
fun main() {
    val nums = arrayOf(1, 2, 3, 4, 5)
    val nums2 = nums.map { num: Int -> num * 2 }
}

//一个参数，无返回值
fun printPlus(str: String) {
    println(str)
}

//两个参数，有返回值
fun printPlus2(str: String, str2: String): String {
    return str + str2
}

fun printPlus3(str: String, str2: String) = str + str2

fun printPlus4(vararg str: String) {
//    println(str)
    for (s in str) {
        println(s)
    }
}

fun whenfunc1(num1: Int): String {
    val res = when (num1) {
        1 -> "one"
        2 -> "two"
        else -> "other"
    }
    return res
}

fun whenfunc2(sss: Int): String = when (sss) {
    in 1..10 -> "one"
    in 11..20 -> "two"
    else -> "other"
}

